package com.chzu.controller;

import com.chzu.pojo.SysRole;
import com.chzu.result.JsonResult;
import com.chzu.result.QueryInfo;
import com.chzu.service.SysRoleService;
import com.chzu.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author lz
 * @Version 1.0
 * @Company 滁州大健康与养老产业研究院
 * @ClassName SysRoleController
 * @Description TODO
 * @Date 2022/02/03 23:14
 */
@RestController
@Api(tags = "角色数据的接口")
@RequestMapping("/role")
public class SysRoleController {

    @Resource
    private SysRoleService roleService;

    @ApiOperation("分页查询角色信息")
    @PostMapping("/findPage")
    public JsonResult<Object> findRole(@RequestBody QueryInfo queryInfo) {
        return roleService.findRole(queryInfo);
    }

    @ApiOperation("添加角色信息")
    @PostMapping("/insert")
    public JsonResult<Object> insertRole(@RequestBody SysRole role) {
        return roleService.insertRole(role);
    }

    @ApiOperation("修改角色信息")
    @PutMapping("/update")
    public JsonResult<Object> updateRole(@RequestBody SysRole role) {
        return roleService.updateRole(role);
    }

    @ApiOperation("删除角色信息")
    @DeleteMapping("/delete/{id}")
    public JsonResult<Object> deleteRole(@PathVariable("id") Integer id) {
        return roleService.deleteRole(id);
    }

    @ApiOperation("查询所有角色信息")
    @GetMapping("/findAllRoles")
    public JsonResult<Object> findAllRoles() {
        return roleService.findAllRoles();
    }
}
